﻿<phoneNavigation:PhoneApplicationPage
                                      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                                      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                                      xmlns:phoneNavigation="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
                                      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                                      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                                      xmlns:vm="clr-namespace:VanGuideWP7.ViewModel"
                                       xmlns:m="clr-namespace:Microsoft.Phone.Controls.Maps;assembly=Microsoft.Phone.Controls.Maps"
                                      xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
                                      xmlns:local="clr-namespace:VanGuideWP7"
									  xmlns:rbc="clr-namespace:RedBit.WindowsPhone.Controls;assembly=RedBit.WindowsPhone.Controls"
                                      xmlns:Custom="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions" x:Class="VanGuideWP7.MainPage"
                                      mc:Ignorable="d"
                                      d:DesignWidth="480"
                                      d:DesignHeight="800"
                                       d:Orientation="Portrait" SupportedOrientations="PortraitOrLandscape">
    
    <phoneNavigation:PhoneApplicationPage.ApplicationBar>
        <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
            <shell:ApplicationBar.MenuItems>
                <shell:ApplicationBarMenuItem x:Name="miLogin" Text="Log in using Twitter" Click="LoginClick" />
				<shell:ApplicationBarMenuItem x:Name="miABout" Text="Help &amp; About" Click="miABout_Click"  />
            </shell:ApplicationBar.MenuItems>
        	<!--<shell:ApplicationBarIconButton IconUri="/Images/ZoomOut.png" Text="Zoom Out" Click="ZoomOutClick" />-->
        	<shell:ApplicationBarIconButton IconUri="/Images/Locate.png" Text="GPS" Click="LocateClick" />
        	<shell:ApplicationBarIconButton IconUri="/icons/appbar.add.rest.png" Text="New Location" Click="NewSharedLandmarkClick" />
        	<shell:ApplicationBarIconButton IconUri="/Images/Pin.png" Text="filter" Click="SettingsClick" />
        </shell:ApplicationBar>
    </phoneNavigation:PhoneApplicationPage.ApplicationBar>

    <Grid x:Name="LayoutRoot"
          Background="{StaticResource PhoneBackgroundBrush}">
        <VisualStateManager.VisualStateGroups>
            <VisualStateGroup x:Name="NewLandmarkStateGroup">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:1">
                        <VisualTransition.GeneratedEasingFunction>
                            <BackEase EasingMode="EaseOut"/>
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="DefaultNewLandmarkState">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="gridNewLandmarkOptions" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="ExpandedNewLandmarkState">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="gridNewLandmarkOptions" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="DetailsExpandedStateGroup">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="gridNewLandmarkOptions" d:IsOptimized="True"/>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="gridNewLandmarkDetails" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
            <VisualStateGroup x:Name="PushPinDetailsStateGroup">
                <VisualStateGroup.Transitions>
                    <VisualTransition GeneratedDuration="0:0:1">
                        <VisualTransition.GeneratedEasingFunction>
                            <BackEase EasingMode="EaseOut"/>
                        </VisualTransition.GeneratedEasingFunction>
                    </VisualTransition>
                </VisualStateGroup.Transitions>
                <VisualState x:Name="DefaultPushPinDetailsState">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.TranslateY)" Storyboard.TargetName="gridPushPinDetails" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
                <VisualState x:Name="ExandedPushPinDetailsState">
                    <Storyboard>
                        <DoubleAnimation Duration="0" To="0" Storyboard.TargetProperty="(UIElement.Projection).(PlaneProjection.RotationX)" Storyboard.TargetName="gridPushPinDetails" d:IsOptimized="True"/>
                    </Storyboard>
                </VisualState>
            </VisualStateGroup>
        </VisualStateManager.VisualStateGroups>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--ContentGrid is empty. Place new content here-->
        <Grid x:Name="ContentGrid" Grid.Row="0">
            <!--<m:Map x:Name="mapMain" 
            		ZoomLevel="10" 
            		ZoomBarVisibility="Collapsed" CacheMode="BitmapCache">
                Points recieved from the service ( multiple layers within )
                <m:MapLayer x:Name="mapLayer" />
                <m:Pushpin x:Name="deviceLocation" Background="Black" Visibility="{Binding CurrentDevicePositionVisible}" Location="{Binding CurrentDevicePosition}"/>
            </m:Map>-->

            <local:LoadingBar
            		LoadingText="{Binding LoadingText}"
            		EnableAnimation="{Binding Loading}"
					Visibility="{Binding LoadingVisibility}" VerticalAlignment="Top" d:IsHidden="True">
                <local:LoadingBar.GridBackground>
                    <SolidColorBrush Color="{StaticResource PhoneSemitransparentColor}"/>
                </local:LoadingBar.GridBackground>
            </local:LoadingBar>

            <Grid x:Name="gridNewLandmarkDetails" Height="300" VerticalAlignment="Top">
                <Grid.Projection>
                    <PlaneProjection CenterOfRotationY="0" RotationX="118"/>
                </Grid.Projection>
                <StackPanel Margin="0,72,0,6" d:LayoutOverrides="VerticalAlignment">
                    <StackPanel.Background>
                        <SolidColorBrush Color="{StaticResource PhoneSemitransparentColor}"/>
                    </StackPanel.Background>
                    <rbc:WatermarkedTextbox x:Name="txtName" Watermark="type in a name for landmark" Text="{Binding NewSharedLandmarkItem.Name, Mode=TwoWay}"/>
                    <rbc:WatermarkedTextbox x:Name="txtDescription" Watermark="type in description for landmark" Text="{Binding NewSharedLandmarkItem.Description, Mode=TwoWay}"/>
                    <Grid Height="72">
                        <Button x:Name="btnHide" rbc:TiltEffect.IsTiltEnabled="True" Content="Hide" HorizontalAlignment="Left" d:LayoutOverrides="Height" VerticalAlignment="Top" >
                            <Custom:Interaction.Triggers>
                                <Custom:EventTrigger EventName="Click">
                                    <ic:GoToStateAction StateName="ExpandedNewLandmarkState"/>
                                </Custom:EventTrigger>
                            </Custom:Interaction.Triggers>
                        </Button>
                        <Button x:Name="btnAddLandmark" rbc:TiltEffect.IsTiltEnabled="True" Click="btnAddLocation_Click" Content="Add Landmark" d:LayoutOverrides="HorizontalAlignment" HorizontalAlignment="Right" VerticalAlignment="Top" >
                            <Custom:Interaction.Triggers>
                                <Custom:EventTrigger EventName="Click">
                                    <ic:GoToStateAction StateName="DefaultNewLandmarkState"/>
                                </Custom:EventTrigger>
                            </Custom:Interaction.Triggers>
                        </Button>
                    </Grid>
                </StackPanel>
            </Grid>

            <Grid x:Name="gridNewLandmarkOptions" VerticalAlignment="Top" Height="72" RenderTransformOrigin="0.5,0.5" >
                <Grid.Projection>
                    <PlaneProjection CenterOfRotationX="1" CenterOfRotationY="0" RotationX="106"/>
                </Grid.Projection>
                <Grid.RenderTransform>
                    <CompositeTransform/>
                </Grid.RenderTransform>
                <Grid.Background>
                    <SolidColorBrush Color="{StaticResource PhoneSemitransparentColor}"/>
                </Grid.Background>
                <Button rbc:TiltEffect.IsTiltEnabled="True" Click="btnCancelAddLocation_Click" x:Name="btnCancel" Content="Cancel" HorizontalAlignment="Left" d:LayoutOverrides="Height" Margin="39,0,0,0" Width="170">
                    <Custom:Interaction.Triggers>
                        <Custom:EventTrigger EventName="Click">
                            <ic:GoToStateAction StateName="DefaultNewLandmarkState"/>
                        </Custom:EventTrigger>
                    </Custom:Interaction.Triggers>
                </Button>
                <Button rbc:TiltEffect.IsTiltEnabled="True" x:Name="btnDetails" Content="Details" HorizontalAlignment="Right" Margin="0,0,28,0" d:LayoutOverrides="Height" Width="170">
                    <Custom:Interaction.Triggers>
                        <Custom:EventTrigger EventName="Click">
                            <ic:GoToStateAction StateName="DetailsExpandedStateGroup"/>
                        </Custom:EventTrigger>
                    </Custom:Interaction.Triggers>
                </Button>
            </Grid>

            <Grid x:Name="gridPushPinDetails" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
                <Grid.RenderTransform>
                    <CompositeTransform/>
                </Grid.RenderTransform>
                <Grid.Projection>
                    <PlaneProjection CenterOfRotationX="0.8" CenterOfRotationY="0" RotationX="120"/>
                </Grid.Projection>
                <Grid.Background>
                    <SolidColorBrush Color="{StaticResource PhoneSemitransparentColor}"/>
                </Grid.Background>
                <StackPanel d:LayoutOverrides="Width">
            		<StackPanel Height="48" Orientation="Horizontal" VerticalAlignment="Top">
                        <Image x:Name="dppImage" Source="{Binding SelectedPushPin.PointOfInterest.IconUri}" Stretch="None" d:LayoutOverrides="Height" />
                        <TextBlock x:Name="dppCategory" FontFamily="{StaticResource PhoneFontFamilySemiBold}" FontSize="{StaticResource PhoneFontSizeMedium}" Text="{Binding SelectedPushPin.Category}" Margin="5,0,0,0" d:LayoutOverrides="Height" VerticalAlignment="Center"  >
            				<TextBlock.Foreground>
            					<SolidColorBrush Color="{StaticResource PhoneAccentColor}"/>
            				</TextBlock.Foreground>
            			</TextBlock>
            		</StackPanel>
            		<TextBlock TextWrapping="Wrap" x:Name="dppDescription" Text="{Binding SelectedPushPin.Description}" Margin="14,0,191,0" FontFamily="{StaticResource PhoneFontFamilyNormal}" FontSize="{StaticResource PhoneFontSizeNormal}" Height="76" />
            	</StackPanel>
                <Button x:Name="btnPushPinDetails" Click="NavigateToDetailsClicked" Content="Details" HorizontalAlignment="Right" Margin="0,65,0,0" d:LayoutOverrides="Height" Width="198" VerticalAlignment="Bottom"/>
            </Grid>
            
        </Grid>

        <ProgressBar x:Name="pb_mapDownloading" IsIndeterminate="{Binding IsDownloading, ElementName=mapMain}" RenderTransformOrigin="0.5,0.5" Style="{StaticResource PerformanceProgressBar}" VerticalAlignment="Top" Visibility="Collapsed">
            <ProgressBar.RenderTransform>
                <CompositeTransform/>
            </ProgressBar.RenderTransform>
        </ProgressBar>
    </Grid>

</phoneNavigation:PhoneApplicationPage>
